<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登陆</title>
</head>
<script type="text/javascript" src="js/jquery.min.js"></script>
<body>
<form>
	<h2>欢迎登录...</h2>
    <table>
        <tr>
            <td><input id="user" type="text" value="">账号</td>
        </tr>
        <tr>
            <td><input id="pwd" type="password">密码</td>
        </tr>
        <tr>
            <td><input type="button" value="用户登录" onclick="login()">
				<input type="button" value="管理员登录" onclick="adminlogin()">
			</td>
        </tr>
    </table>
</form>
</body>
<script>
	//用户登录
    function login() {
		var username = $("#user").val();
		var userpwd = $("#pwd").val();
        // alert(username+" "+userpwd)
		$.ajax({
				// type: "POST",
				url: "http://localhost:8080/user/login/"+username+"/"+userpwd,
				data: {

				},
				// dataType: json,
				success: function(result) {
					console.log(result.status);
					if (result.status == 200) {
						alert(result.msg)
						window.location = "http://localhost:8080/demo/index.html"
					} else{
						alert(result.msg)
					}
				},
				error:function(){
					alert("服务器异常")
				}
				
			})
    }
	//管理员登录
	function adminlogin() {
		var username = $("#user").val();
		var userpwd = $("#pwd").val();
        // alert(username+" "+userpwd)
		$.ajax({
				// type: "POST",
				url: "http://localhost:8080/user/adminlogin/"+username+"/"+userpwd,
				// dataType: json,
				success: function(result) {
					console.log(result.status);
					if (result.status == 200) {
						alert(result.msg)
						window.location = "http://localhost:8080/demo/admin.html"
					} else{
						alert(result.msg)
					}
				},
				error:function(){
					alert("服务器异常")
				}
				
			})
    }
</script>
</html>